﻿<%@ Control Language="C#" Inherits="Yuanlin.Business.CompanyProductListControl, Yuanlin.Business" AutoEventWireup="true" %>

<script language="javascript" type="text/javascript">
<!--
function deleteEntitys(){

    var check = document.getElementsByName("entity_id");
	var ifSelect;
	var entityIDs = '';
	for(var i=0;i<check.length;i++){
		if(check[i].checked==true){
		    if(entityIDs == '')
		        entityIDs = check[i].value;
		    else
		        entityIDs = entityIDs + ":" + check[i].value;
			ifSelect = true;
		}
	}
	if(ifSelect == true){
		var delSelect = confirm("确认删除这些花木吗？");
		if(delSelect == false){
			return;
		}
		AjaxMethod.DeleteCompanyProducts('<%=ClientID %>', entityIDs, refreshPage);
	}
	else{
		alert("请选择要删除的记录！");
	}

}

function updateEntitys(){

    var check = document.getElementsByName("entity_id");
	var ifSelect;
	var entityIDs = '';
	for(var i=0;i<check.length;i++){
		if(check[i].checked==true){
		    if(entityIDs == '')
		        entityIDs = check[i].value;
		    else
		        entityIDs = entityIDs + ":" + check[i].value;
			ifSelect = true;
		}
	}
	if(ifSelect == true){
		var delSelect = confirm("确认更新这些花木吗？");
		if(delSelect == false){
			return;
		}
		AjaxMethod.UpdateCompanyProducts('<%=ClientID %>', entityIDs, refreshPage);
	}
	else{
		alert("请选择要更新的记录！");
	}

}

function updateCheckAllChecked(check){
    var checkAll = document.getElementById("CheckAll");
    if(!check.checked){
        checkAll.checked = false;
    }
    else
    {
        var ifAllSelect = true;
        var check = document.getElementsByName("entity_id");
        for(var i=0;i<check.length;i++){
		    if(check[i].checked==false){
			    ifAllSelect = false;
		    }
	    }
	    if(ifAllSelect == true){
            checkAll.checked = true;
	    }
    }
}

function toggleAllCheck(checkAll){
    var check = document.getElementsByName("entity_id");
    for(var i=0;i<check.length;i++){
	    check[i].checked=checkAll.checked;
    }
}

function deleteEntity(entityID){
	var bool = confirm("确认删除该花木吗？");
	if(bool == false){
		return;
	}
	AjaxMethod.DeleteCompanyProduct('<%=ClientID %>', entityID, refreshPage);
}

function updateEntity(entityID){
	var bool = confirm("确认更新该花木吗？");
	if(bool == false){
		return;
	}
	AjaxMethod.UpdateCompanyProduct('<%=ClientID %>', entityID, refreshPage);
}

function refreshPage(res)
{
    window.location.reload();
    var checkAll = document.getElementById("CheckAll");
    checkAll.checked = false;
    toggleAllCheck(checkAll);
}
function CompanyProductAddUrl()
{
    if('<%= tradeType %>' =="0")
    {
        window.location.href='<%=  SiteUrls.Instance().GetCompanyProductAddUrl()%>';
    }
    else if('<%= tradeType %>' =="2")
    {
        window.location.href='<%=  SiteUrls.Instance().GetCompanyProductQiuGouAddUrl()%>';
    }
    else if('<%= tradeType %>' =="1")
    {
        window.location.href='<%=  SiteUrls.Instance().GetCompanyProductJingPinAddUrl()%>';
    }
    else if('<%= tradeType %>' =="3")
    {
        window.location.href='<%=  SiteUrls.Instance().GetCompanyProductJiShouAddUrl()%>';
    }
}
function CompanyProductEditUrl(id)
{
    if('<%= tradeType %>' =="0")
    {
        window.location.href= 'companyproduct/edit.aspx?companyproductid='+id+'&tradetype=0';
    }
    else if('<%= tradeType %>' =="2")
    {
        window.location.href= 'companyproduct/edit.aspx?companyproductid='+id+'&tradetype=2';
    }
    else if('<%= tradeType %>' =="1")
    {
       window.location.href= 'companyproduct/edit.aspx?companyproductid='+id+'&tradetype=1';
    }
    else if('<%= tradeType %>' =="3")
    {
       window.location.href= 'companyproduct/edit.aspx?companyproductid='+id+'&tradetype=3';
    }
}
//-->
</script>

<fieldset>
	<legend><%= CategoryName%>花木管理</legend>	
			
    <asp:Repeater id="list" runat="server">
        <HeaderTemplate>
            <table border="0" cellpadding="0" cellspacing="0" class="AdminTable">
	            <thead>
		            <tr>
			            <th class="NumCol"><input type="checkbox" onclick="toggleAllCheck(this)" id="CheckAll" title="全选/取消全选" /></th>
			            <th class="TitleCol">常用名</th>
			            <th class="CountCol">状态</th>
			            <th class="BigActionCol">更新日期</th>
			            <th class="ActionCol">操作</th>
		            </tr>
	            </thead>
	            <tbody>
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
			    <td class="NumCol">
				    <input type="checkbox" onclick="updateCheckAllChecked(this)" name="entity_id" id="entity_id" value="<%# ((CompanyProduct)Container.DataItem).EntityId.Value %>"/>
			    </td>
			    <td class="TitleCol">
				    <a href="javascript:CompanyProductEditUrl(<%# ((CompanyProduct)Container.DataItem).EntityId.Value %>)">
					    <%# DataBinder.Eval(Container.DataItem, "Title")%>
				    </a>
			    </td>
			    <td class="BigActionCol">
			        <%# ((CompanyProduct)Container.DataItem).Verify.Value == 1 ? "已审核" : "审核中"%>
			    </td>
			    <td class="BigActionCol">
			        <%# ((CompanyProduct)Container.DataItem).UpdateDate.Value.ToShortDateString()%>
			    </td>
			    <td class="ActionCol">
			        <!-- INSERT POSITION -->
					<a class="" href="javascript:void(0);" onclick="deleteEntity(<%# ((CompanyProduct)Container.DataItem).EntityId.Value %>)" alt="删除" title="删除"><span>删除</span></a>
					<a class="" href="javascript:void(0);" onclick="updateEntity(<%# ((CompanyProduct)Container.DataItem).EntityId.Value %>)" alt="更新发布日期" title="更新发布日期"><span>更新</span></a>
			    </td>
		    </tr>
        </ItemTemplate>
        <FooterTemplate>
			    </tbody>
	        </table>
	        <div class="FormRow ButtonRow">
		        <input type="button" class="Button" onclick="deleteEntitys()" value="删除选择"/>
		        <font color="red"></font>&nbsp;&nbsp;&nbsp;&nbsp;
		        <input type="button" class="Button" onclick="updateEntitys()" value="更新选择"/>
		        <font color="red"></font>&nbsp;&nbsp;&nbsp;&nbsp;
		        <input type="button" class="Button" onclick="CompanyProductAddUrl()" value="添加"/>
	        </div>
        </FooterTemplate>
    </asp:Repeater>
    <div class="PagingWrapper">
        <asp:Panel  Runat="server" align="right" CssClass="CommonPagingArea">
            <nwap:CurrentPage Cssclass="columnText" id="currentPage" runat="server" />
            <nwap:Pager id="pager" runat="server" PageSize="14" />
        </asp:Panel>
    </div>
</fieldset>